import { fromJS } from 'immutable';
import * as types from './actionTypes';
const defaultState = fromJS({
    topicList: [],
    articleList: [],
    recommendPicList: [],
    qrcode: {},
    listPage: 1,
    listHasMore: true
});

export default (state = defaultState, action) => {
    switch(action.type) {
        case types.GET_HOME_DATA:
            return state.merge({
                topicList: action.topicList,
                articleList: action.articleList,
                recommendPicList: action.articleList,
                qrcode: action.qrcode
            });
        case types.GET_MORE_LIST_DATA:
            return state.merge({
                topicList: state.topicList.concat(action.data),
                listPage: action.newPage,
                listHasMore: action.hasMore
            });
        default :
            return state;
    }
};